@extends('home/base/person')
@section('information')
	<head>
		<meta charset="utf-8">
		<meta name="viewport" content="width=device-width, initial-scale=1.0,maximum-scale=1.0, user-scalable=0">

		<title>个人资料</title>

		<link href="{{ asset('AmazeUI-2.4.2/assets/css/admin.css') }}" rel="stylesheet" type="text/css">
		<link href="{{ asset('AmazeUI-2.4.2/assets/css/amazeui.css') }}" rel="stylesheet" type="text/css">
		<link href="{{ asset('css/personal.css') }}" rel="stylesheet" type="text/css">
		<link href="{{ asset('css/infstyle.css') }}" rel="stylesheet" type="text/css">
		
		<script src="{{ asset('AmazeUI-2.4.2/assets/js/jquery.min.js') }}"></script>
		<script src="{{ asset('AmazeUI-2.4.2/assets/js/amazeui.js') }}"></script>			
	</head>
	<body>
		<div class="center">
					@if(session('msg'))
				        	<div class="am-btn am-btn-danger">
							{{ session('msg') }}
							<i class="icon"></i>
							</div>
				        @endif
				        @if(session('error'))
				        	<div class="am-btn am-btn-danger">
							{{ session('error') }}
							<i class="icon"></i>
							</div>
						@endif
					<div class="user-info">
						<!--标题-->
						<div class="am-cf am-padding">
							<div class="am-fl am-cf"><strong class="am-text-danger am-text-lg">个人资料</strong> / <small>Personal&nbsp;information</small></div>
						</div>
						<hr/>
						@foreach($grxx as $v)
						<form class="am-form am-form-horizontal" action="{{ url('home/person/information') }}" method='post' enctype='multipart/form-data'>
						{{ csrf_field() }}
						{{ method_field('POST') }}
						<!--头像-->
						<div class="user-infoPic">

							<div class="filePic">
								<input type="file" id="fileupload" class="inputPic" name='upic' allowexts="gif,jpeg,jpg,png,bmp" accept="image/*">
								<img id="imageview" class="am-circle am-img-thumbnail" src="{{ url('admin/upload/'.$v->upic)  }}" alt="图片加载不成功" />
							</div>
						
							<p class="am-form-help">头像</p>

							<div class="info-m">
								<div><b>用户名：<i>{{ $v->username }}</i></b></div>
								<div class="vip">
                                      <span></span><a href="#">会员专享</a>
								</div>
							</div>
						</div>

						<!--个人信息-->
						<div class="info-main">
							

								<div class="am-form-group">
									<label for="user-name" class="am-form-label">个性签名</label>
									<div class="am-form-content">
										<input type="text" id="user-name2" name='info' value='{{ $v->info }}'><span></span>
                                         
									</div>
								</div>

								<div class="am-form-group">
									<label class="am-form-label">性别</label>
									<div class="am-form-content sex">
										<label class="am-radio-inline">
											<input type="radio" name="sex" value="1"@if($v->sex == 1) checked data-am-ucheck @endif> 男
										</label>
										<label class="am-radio-inline">
											<input type="radio" name="sex" value="2"@if($v->sex == 2) checked data-am-ucheck @endif> 女
										</label>
									</div>
								</div>

								<div class="am-form-group">
									<label for="user-email" class="am-form-label">电子邮件</label>
									<div class="am-form-content">
										<input id="user-email" placeholder="Email" type="email" name='email' value="{{ $v->email }}">
									</div>
								</div>
					
								<div class="info-btn">
									<div ><input type='submit' class="am-btn am-btn-danger" value='保存提交'></div>

								</div>
							</form>
						@endforeach
						</div>
					</div>
			
		</div>
	</body>
	<script type="text/javascript">
	$(function() {  
		    //原理是把本地图片路径："D(盘符):/image/..."转为"http://..."格式路径来进行显示图片 
		    $("#fileupload").change(function() {  
		        var $file = $(this);  
		        var objUrl = $file[0].files[0];  
		        //获得一个http格式的url路径:mozilla(firefox)||webkit or chrome  
		        var windowURL = window.URL || window.webkitURL;  
		        //createObjectURL创建一个指向该参数对象(图片)的URL  
		        var dataURL;  
		        dataURL = windowURL.createObjectURL(objUrl);  
		        $("#imageview").attr("src",dataURL);  
		    });  
		});

	//文本框失去焦点后
	$('form :input').blur(function(){
	var $parent = $(this).parent().next();
	$parent.find(".formtips").remove();
	//验证用户名
	if( $(this).is('#user-name2') ){
	 if( this.value=="" || this.value.length < 6 ){
	  var errorMsg = '请输入至少6位的个性签名.';
	  $parent.append('<span class="formtips onError">'+errorMsg+'</span>');
	 }else{
	  // var okMsg = '输入正确.';
	  $parent.append('<span class="formtips onSuccess"></span>');
	 }
	}

	//验证邮件
	if( $(this).is('#user-email') ){
	if( this.value=="" || ( this.value!="" && !/.+@.+\.[a-zA-Z]{2,4}$/.test(this.value) ) ){
            var errorMsg = '请输入正确的E-Mail地址.';
			$parent.append('<span class="formtips onError">'+errorMsg+'</span>');
		}else{
            var okMsg = '输入正确.';
			$parent.append('<span class="formtips onSuccess">'+okMsg+'</span>');
		}
	}
})
	</script>


</html>
@endsection